//app.js
import {
  UserModels
} from "./utils/models/user/User-models";
var userModel = new UserModels;
App({
  onLaunch: function () {
    const accountInfo = wx.getAccountInfoSync();
    this.globalData.accountInfo = accountInfo
    // 适配手机顶部
    this.globalData.headerBtnPosi = wx.getMenuButtonBoundingClientRect()
    let that = this
    wx.getSystemInfo({ // iphonex底部适配
      success: async (res) => {
        that.globalData.systeminfo = res
        // console.log(res);
        // 判断iphone
        const model = res.model;
        const modelInclude = ["iPhone X", 'iPhone XR', "iPhone XS", "iPhone XS MAX"];
        this.globalData.isIphone = modelInclude.some((res) => {
          return model.indexOf(res) != -1
        })
      }
    })

    let statusBarHeight = this.globalData.systeminfo.statusBarHeight
    let headerPosi = this.globalData.headerBtnPosi
    let btnPosi = { // 胶囊实际位置，坐标信息不是左上角原点
      height: headerPosi.height,
      width: headerPosi.width,
      top: headerPosi.top - statusBarHeight, // 胶囊top - 状态栏高度
      bottom: headerPosi.bottom - headerPosi.height - statusBarHeight, // 胶囊bottom - 胶囊height - 状态栏height （胶囊实际bottom 为距离导航栏底部的长度）
      right: this.globalData.systeminfo.screenWidth - headerPosi.right // 屏幕宽度 - 胶囊right
    }

    this.globalData.navbarHeight = headerPosi.bottom + btnPosi.bottom // 胶囊bottom + 胶囊实际bottom


    // 获取屏幕高度
    this.globalData.windowHeight = wx.getSystemInfoSync().windowHeight
    this.globalData.screenHeight = wx.getSystemInfoSync().screenHeight

    let token = wx.getStorageSync('token');
    let userinfo = wx.getStorageSync('userinfo');
    let expire_time = userinfo.expire_time;
    let timestamp = (new Date()).getTime();
  },

  
  globalData: {
    headerBtnPosi: '',
		systeminfo: '',
		navbarHeight: '',
		windowHeight: '',
    screenHeight:'',
    accountInfo: [],
  },
})